#ifndef __THREAD_H__
#define __THREAD_H__

#include <pthread.h>
#include <functional>
#include <string>

using std::string;
using std::function;

extern __thread const char* name;

using ThreadCallback=function<void()>;
class Thread
{
public:
    Thread(ThreadCallback &&cb,const string &name);
    ~Thread();
    void start();
    void stop();

private:
    static void *threadFunc(void *arg);
    
private:
    pthread_t _thid;
    bool _isRunning;
    string _name;         //线程名字
    ThreadCallback _cb;
};

#endif
